package com.xbongbong.pro.businesstage.pojo.dto;

import com.xbongbong.paas.field.FilterConditionsPoJo;
import com.xbongbong.paas.toolbox.wrap.BaseDTO;
import com.xbongbong.pro.businesstage.pojo.StageWorkPojo;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.Size;
import java.util.List;
import java.util.Objects;

/**
 * 客户阶段保存
 * @author haibin.zhang
 * @version v1.0
 * @date 2019/2/13 20:52
 * @since v1.0
 */
@Getter
@Setter
@ToString
public class CustomerStageSaveDTO extends BaseDTO {
    /**
     * 表单id
     */
    private Long formId;
    /**
     * 阶段id
     */
    private Long id;
    /**
     * 是否启用
     */
    @Range(min = 0, max = 1, message = "{dto.msg.customerStageSave.enable.Range}")
    private Integer enable;
    /**
     * 阶段名称
     */
    @Size(min = 1,max = 50,message = "{dto.msg.customerStageSave.name.Size}")
    private String name;
    /**
     * 客户状态
     */
    private Integer customerStatus;
    /**
     * 线索状态
     */
    private Integer clueStatus;
    /**
     * 是否开启管理客户状态
     */
    @Range(min = 0, max = 1, message = "{dto.msg.customerStageSave.openStatus.Range}")
    private Integer openStatus;
    /**
     * 是否开启工作
     */
    @Range(min = 0, max = 1, message = "{dto.msg.customerStageSave.openWork.Range}")
    private Integer openWork;
    /**
     * 工作
     */
    @Size(max = 50,message = "{dto.msg.customerStageSave.stageWorkList.Size}")
    private List<StageWorkPojo> stageWorkList;
    /**
     * 赢率
     */
    private Integer estimateWinRate;
    /**
     * 阶段跳转前置条件
     */
    @Size(max = 5, message = "{dto.msg.customerStageSave.preConditions.Size}")
    private List<FilterConditionsPoJo> preConditions;
    /**
     * 是否开启前置跳转
     */
    @Range(min = 0, max = 1, message = "{dto.msg.customerStageSave.enablePreCheck.Range}")
    private Integer enablePreCheck;

    public void setEstimateWinRate(Integer estimateWinRate) {
        if (Objects.isNull(estimateWinRate)){
            estimateWinRate = 0;
        }
        this.estimateWinRate = estimateWinRate;
    }
}
